<html>
<head><meta charset="utf-8"><title>structural equality meeting (cg sidetrack) · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/structural.20equality.20meeting.20(cg.20sidetrack).html">structural equality meeting (cg sidetrack)</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="248622148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/structural%20equality%20meeting%20%28cg%20sidetrack%29/near/248622148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/structural.20equality.20meeting.20(cg.20sidetrack).html#248622148">(Aug 06 2021 at 15:04)</a>:</h4>
<blockquote>
<p>make <code>StructuralEq</code> recursive and autogenerate <code>T: StructuralEq</code> bounds for all <code>T</code> that are used in const generic parameters' types like <code>fn foo&lt;T, const C: T&gt;</code>.</p>
</blockquote>
<p>that seems very difficult to get right.</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nc">const</span><span class="w"> </span><span class="nb">Default</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">bar</span>::<span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">T</span>::<span class="n">default</span><span class="p">()</span><span class="w"> </span><span class="p">}</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">bar</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="nc">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</code></pre></div>
<p>how do we add the <code>T: StructuralEq</code> bound to <code>foo</code>? Do we fail to compile, if so, how do we modify this snippet to make it compile?</p>



<a name="248635085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/structural%20equality%20meeting%20%28cg%20sidetrack%29/near/248635085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/structural.20equality.20meeting.20(cg.20sidetrack).html#248635085">(Aug 06 2021 at 16:37)</a>:</h4>
<p>hmm... true</p>



<a name="248635092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/structural%20equality%20meeting%20%28cg%20sidetrack%29/near/248635092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/structural.20equality.20meeting.20(cg.20sidetrack).html#248635092">(Aug 06 2021 at 16:37)</a>:</h4>
<p>that doesn't work nicely</p>



<a name="248635232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/structural%20equality%20meeting%20%28cg%20sidetrack%29/near/248635232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/structural.20equality.20meeting.20(cg.20sidetrack).html#248635232">(Aug 06 2021 at 16:38)</a>:</h4>
<p>yea I think we need to expose the trait for that so users can write it</p>



<a name="248635268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/structural%20equality%20meeting%20%28cg%20sidetrack%29/near/248635268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/structural.20equality.20meeting.20(cg.20sidetrack).html#248635268">(Aug 06 2021 at 16:39)</a>:</h4>
<p>could still make implementing it behind a feature gate as an intermediate step</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>